package com.go.where.family.service.impl;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.go.where.family.dao.AccountRelationDao;
import com.go.where.family.dao.CustomerDao;
import com.go.where.family.pojo.AccountRelationInfo;
import com.go.where.family.pojo.CustomerInfo;
import com.go.where.family.scoket.Head;
import com.go.where.family.service.CustomerService;

@Service("customerService")
public class CustomerServiceImpl implements CustomerService {

	@Resource(name = "customerDao")
	private CustomerDao customerDao;
	@Resource(name = "accountRelationDao")
	private AccountRelationDao accountRelationDao;

	@Override
	public String getNextInviteCode() {
		return customerDao.getNextKey();
	}

	@Override
	public CustomerInfo queryByPrimaryKey(String id, Head head) {
		CustomerInfo user = new CustomerInfo();
		user.setCustomerId(id);
		return this.customerDao.queryByPrimaryKey(user);
	}

	@Override
	public CustomerInfo queryByCustomerNick(String nick, Head head) {
		return customerDao.queryByCustomerNick(nick);
	}

	@Override
	public int save(CustomerInfo userInfo, Head head) {
		return this.customerDao.insert(userInfo);
	}

	@Override
	public int update(CustomerInfo userInfo, Head head) {
		return this.customerDao.update(userInfo);
	}

	@Override
	public CustomerInfo queryByMyInviteCode(String myInviteCode, Head head) {
		return this.customerDao.queryByMyInviteCode(myInviteCode);
	}

	@Override
	public int updatePwd(CustomerInfo info, Head head) {
		return this.customerDao.updatePwd(info);
	}

	@Override
	public CustomerInfo queryByMobile(String mobile, Head head) {
		return this.customerDao.queryByMobile(mobile);
	}

	@Override
	public List<CustomerInfo> getUserListByUserIds(Map<String, Object> para) {
		return this.customerDao.getUserListByUserIds(para);
	}

	@Override
	public List<CustomerInfo> queryPage(Map<String, Object> para) {
		return this.customerDao.queryT(para);
	}

	@Override
	public List<CustomerInfo> getUserListByMobiles(Map<String, Object> para) {
		return this.customerDao.getUserListByMobiles(para);
	}

	@Override
	public List<String> getUserIdList(Map<String, Object> para) {
		return this.customerDao.getUserIdList(para);
	}

	@Override
	public Integer queryCount(Map<String, Object> para) {
		return this.customerDao.queryCount(para);
	}

	@Override
	public int saveBindAccount(AccountRelationInfo accountRelationInfo) {
		accountRelationInfo.setId(UUID.randomUUID().toString());
		return accountRelationDao.insert(accountRelationInfo);
	}

	@Override
	public int deleteBindAccount(AccountRelationInfo accountRelationInfo) {
		return accountRelationDao.delete(accountRelationInfo);
	}

	@Override
	public List<AccountRelationInfo> queryAccRelaByParameter(
			AccountRelationInfo accountRelationInfo) {
		return accountRelationDao.queryAccRelaByParameter(accountRelationInfo);
	}

	@Override
	public int updateBindAccount(AccountRelationInfo accountRelationInfo) {
		return accountRelationDao.update(accountRelationInfo);
	}

}
